#ifndef __ADC_H
#define __ADC_H	 

#include "Sys.h" 


/* Private constants ---------------------------------------------------------*/

/** @defgroup ADC_Private_Constants ADC Private Constants
  * @{
  */

/* Fixed timeout values for ADC conversion (including sampling time)        */
/* Maximum sampling time is 810.5 ADC clock cycle        */
/* Maximum conversion time is 16.5 + Maximum sampling time                  */
/*                       or 16.5  + 810.5 = 827 ADC clock cycles            */
/* Minimum ADC Clock frequency is 0.35 MHz                                  */
/* Maximum conversion time is                                               */
/*              827 / 0.35 MHz = 2.36 ms                                    */
//#define ADC_STOP_CONVERSION_TIMEOUT     ((uint32_t) 5)

/* Delay for temperature sensor stabilization time.                         */
/* Maximum delay is 120us (refer device datasheet, parameter tSTART).       */
/* Unit: us                                                                 */
//#define ADC_TEMPSENSOR_DELAY_US         ((uint32_t) 120)

/* Delay for ADC voltage regulator startup time                               */
/*  Maximum delay is 10 microseconds                                          */
/* (refer device RM, parameter Tadcvreg_stup).                                */
//#define ADC_STAB_DELAY_US               ((uint32_t) 10)     /*!< ADC voltage regulator startup time */



// 
class Adc : public Object
{
// Construction
public:
	Adc(ADC_TypeDef * pInstance, u8 nLen);
		
// Properties
public:
	ADC_TypeDef * m_pInstance;
	ADC_Common_TypeDef * m_pCommon;

private:

// Methods
public:
	u32 get(u8 ch); 
	void start( u16 nLen );
	bool configChannel(uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime);

// Overwrite
public:
	virtual void close();
};

#endif
